<template>
  <div class="beautyItem" @click="itemClick">
    <img v-lazy="showImage" alt="" @load="loadOk" />
    <div class="beauty-info">
      <p>{{ goodsItem.title }}</p>
      <span class="price">{{ goodsItem.price }}</span>
      <span class="collect">{{ goodsItem.cfav }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "beautyItem",
  props: {
    goodsItem: {
      typeof: Object,
      default() {
        return {};
      },
    },
  },
  computed: {
    showImage() {
      return (
        this.goodsItem.img || this.goodsItem.image || this.goodsItem.show.img
      );
    },
  },
  methods: {
    loadOk() {
      this.$bus.emit("loadOk");
    },
    itemClick() {
      if (Object.keys(this.goodsItem).length !== 0) {
        const iid = this.goodsItem.iid;
        this.$router.push({ path: "/detail/", query: { iid } });
      }
    },
  },
};
</script>

<style scoped>
.beautyItem {
  width: 48%;
  position: relative;
  text-align: center;
  font-size: 12px;
  padding-bottom: 40px;
}
.beautyItem img {
  width: 100%;
  border-radius: 10px;
  /* height: 267px; */
  min-height: 100%;
}
.price {
  color: var(--color-tint);
  margin-right: 20px;
}
.beautyItem p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.beauty-info {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  overflow: hidden;
}
.beauty-info .collect {
  position: relative;
}
.beauty-info .collect::before {
  content: "";
  position: absolute;
  left: -15px;
  top: -1px;
  width: 14px;
  height: 14px;
  background: url("~assets/img/common/collect.svg") 0 0/14px 14px;
}
</style>